<%--
    Document   : warehouses
    Created on : Nov 6, 2009, 1:18:13 AM
    Author     : moustafa
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page import="java.util.ArrayList" %>
<%@page import="java.util.Iterator" %>
<%@page import="model.Product" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">


<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Products</title>
    </head>
    <body>
        <table border="1" cellspacing="1" cellpadding="1">
            <thead>
                <tr>
                    <th>Product Name</th>
                    <th>Product Description</th>
                    <th>Product Image</th>
                    <th>List Price</th>
                    <th>Minimum Price</th>
                    <th>Status</th>
                    <th>Edit Product Info.</th>
                </tr>
            </thead>
            <tbody>
                <tr >
                    <td></td>
                </tr>
                <%
                ArrayList <Product> products = (ArrayList <Product>)request.getSession(false).getAttribute("products");
                int pageIndex = Integer.parseInt((String)request.getSession(false).getAttribute("page"));
                //int pageIndex = 0;
                for(int i = 0; i < 5; i++){
                int index = i + 5 * pageIndex;
                if(index >= products.size() || index < 0)
                    break;
                Product product = products.get(index);
                 %>

                 <%=
                 "<tr>"+
                    "<td>" + product.getName() + "</td>"+
                    "<td>" + product.getDescription() + "</td>"+
                    "<td><img src='../images/" + product.getImageURL() + "' width='100' height='100'/></td>"+
                    "<td>" + product.getListPrice() + "</td>"+
                    "<td>" + product.getMinPrice() + "</td>"+
                    "<th>" + product.getStatus() + "  " + "</th>"+
                    "<td align='center'>" +
                    "<form action='../admin_pages/edit_product.jsp' method='POST'>" +
                    "<input type='hidden' name='product_id' value='" + product.getID() + "'/>" +
                    "<input type='hidden' name='product_name' value='" + product.getName() + "'/>" +
                    "<input type='hidden' name='product_description' value='" + product.getDescription() + "'/>" +
                    "<input type='hidden' name='product_image' value='" + product.getImageURL() + "'/>" +
                    "<input type='hidden' name='product_status' value='" + product.getStatus() + "'/>" +
                    "<input type='hidden' name='product_list_price' value='" + product.getListPrice() + "'/>" +
                    "<input type='hidden' name='product_min_price' value='" + product.getMinPrice() + "'/>" +
                    "<input type='submit' value='Edit'/>" +
                    "</form>" +
                    "</td>"+
                 "</tr>"
                 %>
                 <%
                 }
                 %>
                 <tr>
                     <td align="center">
                         <form action="../admin/nextproducts">
                             <input type="hidden" name="type" value="back" />
                             <input type="submit" value="<< Back"/>
                        </form>
                     </td>
                     <td colspan="5"></td>
                     <td align="center">
                         <form action="../admin/nextproducts">
                             <input type="hidden" name="type" value="next" />
                             <input type="submit" value="Next >>"/>
                        </form>
                     </td>
                 </tr>
            </tbody>
        </table>
            <form action="/oes/admin_pages/add_product.jsp">
                <input type="submit" value="Add Product" />
            </form>
    </body>
</html>
